<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryRef"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="学号" prop="stuCode">
        <el-input
          v-model="queryParams.stuCode"
          placeholder="请输入学号"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>

      <el-form-item label="学生姓名" prop="realname">
        <el-input
          v-model="queryParams.realname"
          placeholder="请输入学生姓名"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>

      <el-form-item label="身份证" prop="idCard">
        <el-input
          v-model="queryParams.idCard"
          placeholder="请输入身份证"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="手机" prop="phone">
        <el-input
          v-model="queryParams.phone"
          placeholder="请输入手机"
          clearable
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="学院" prop="collegeId">
        <el-select
          v-model="queryParams.collegeId"
          placeholder="请选择二级学院"
          clearable
          style="width: 200px"
        >
          <el-option
            v-for="item in collegeList"
            :key="item.collegeId"
            :label="item.collegeName"
            :value="item.collegeId"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="班级" prop="clsId">
        <el-select
          v-model="queryParams.clsId"
          placeholder="请选择班级"
          clearable
          filterable
          style="width: 200px"
        >
          <el-option
            v-for="item in clsQueryList"
            :key="item.clsId"
            :label="item.clsName"
            :value="item.clsId"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="方向" prop="directionId">
        <el-select
          v-model="queryParams.directionId"
          placeholder="请选择方向"
          clearable
          style="width: 200px"
        >
          <el-option
            v-for="item in directionList"
            :key="item.id"
            :label="item.directionName"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="书院" prop="dormbuildingId">
        <el-select
          v-model="queryParams.dormbuildingId"
          placeholder="请选择书院"
          clearable
          style="width: 200px"
        >
          <el-option
            v-for="item in dormbuildingList"
            :key="item.dormbuildingId"
            :label="item.dormbuildingName"
            :value="item.dormbuildingId"
          />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="Plus"
          @click="handleAdd"
          v-hasPermi="['system:student:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="Edit"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:student:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="Delete"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:student:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          plain
          icon="Upload"
          @click="handleImport"
          v-hasPermi="['system:student:import']"
          >导入</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="Download"
          @click="handleExport"
          v-hasPermi="['system:student:export']"
          >导出</el-button
        >
      </el-col>
      <right-toolbar
        v-model:showSearch="showSearch"
        @queryTable="getList"
        :columns="columns"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="studentList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column
        type="selection"
        width="55"
        align="center"
        v-if="columns[0].visible"
      />
      <el-table-column
        label="学生id"
        align="center"
        prop="userId"
        v-if="columns[1].visible"
      />
      <el-table-column
        label="学号"
        align="center"
        prop="stuCode"
        v-if="columns[2].visible"
      />
      <el-table-column
        label="学生姓名"
        align="center"
        prop="realname"
        v-if="columns[3].visible"
      />
      <el-table-column
        label="手机"
        align="center"
        prop="phone"
        v-if="columns[4].visible"
      />
      <el-table-column
        label="用户性别"
        align="center"
        prop="sex"
        v-if="columns[5].visible"
      />
      <el-table-column
        label="出生日期"
        align="center"
        prop="birthday"
        width="180"
        v-if="columns[6].visible"
      >
        <template #default="scope">
          <span>{{ parseTime(scope.row.birthday, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="身份证"
        align="center"
        prop="idCard"
        v-if="columns[7].visible"
      />
      <el-table-column
        label="政治面貌"
        align="center"
        prop="politicalStatus"
        v-if="columns[8].visible"
      />
      <el-table-column
        label="民族"
        align="center"
        prop="ethnicity"
        v-if="columns[9].visible"
      />

      <el-table-column
        label="籍贯"
        align="center"
        prop="nativePlace"
        v-if="columns[10].visible"
      />
      <el-table-column
        label="住址"
        align="center"
        prop="address"
        v-if="columns[11].visible"
      />
      <el-table-column
        label="生源地"
        align="center"
        prop="sourcePlace"
        v-if="columns[12].visible"
      />
      <el-table-column
        label="户口性质"
        align="center"
        prop="householdType"
        v-if="columns[13].visible"
      />
      <el-table-column
        label="书院名称"
        align="center"
        prop="dormbuildingName"
        v-if="columns[14].visible"
      />
      <el-table-column
        label="宿舍名称"
        align="center"
        prop="dormName"
        v-if="columns[15].visible"
      />
      <el-table-column
        label="学院"
        align="center"
        prop="collegeName"
        v-if="columns[16].visible"
      />
      <el-table-column
        label="专业名称"
        align="center"
        prop="majorName"
        v-if="columns[17].visible"
      />
      <el-table-column
        label="班级名称"
        align="center"
        prop="clsName"
        v-if="columns[18].visible"
      />
      <el-table-column label="方向" align="center" v-if="columns[24].visible">
        <template #default="scope">
          {{ getDirectionName(scope.row.directionId) }}
        </template>
      </el-table-column>
      <el-table-column
        label="银行卡"
        align="center"
        prop="bankCard"
        v-if="columns[19].visible"
      />
      <el-table-column
        label="开户行"
        align="center"
        prop="issuingBank"
        v-if="columns[20].visible"
      />

      <el-table-column
        label="监护人"
        align="center"
        prop="emergencyContact"
        v-if="columns[21].visible"
      />
      <el-table-column
        label="家人电话"
        align="center"
        prop="emergencyPhone"
        v-if="columns[22].visible"
      />
      <el-table-column
        label="状态"
        align="center"
        prop="status"
        v-if="columns[23].visible"
      />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button
            link
            type="primary"
            icon="Edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:student:edit']"
            >修改</el-button
          >
          <el-button
            link
            type="primary"
            icon="Delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['system:student:remove']"
            >删除</el-button
          >
          <el-button
            link
            type="success"
            icon="DataAnalysis"
            @click="navigateToMultiDimensionalAnalysis(scope.row.stuCode, scope.row.realname)"
            v-hasPermi="['system:student:analysis']"
            >分析</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改学生管理对话框 -->
    <el-dialog :title="title" v-model="open" width="600px" append-to-body>
      <el-form ref="studentRef" :model="form" :rules="rules" label-width="80px">
        <el-row :gutter="1">
          <el-col :span="12">
            <el-form-item label="学号" prop="stuCode">
              <el-input
                v-model="form.stuCode"
                placeholder="请输入学号"
                :validate-event="false"
              /> </el-form-item
          ></el-col>
          <el-col :span="12"
            ><el-form-item label="学生姓名" prop="realname">
              <el-input
                v-model="form.realname"
                placeholder="请输入学生姓名"
              /> </el-form-item
          ></el-col>
        </el-row>

        <el-row :gutter="1">
          <el-col :span="12"
            ><el-form-item label="手机" prop="phone">
              <el-input v-model="form.phone" placeholder="请输入手机" /> </el-form-item
          ></el-col>
          <el-col :span="12">
            <el-form-item prop="sex" label="性别">
              <el-select v-model="form.sex" placeholder="请选择">
                <el-option
                  v-for="dict in sys_user_sex"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.label"
                ></el-option>
              </el-select> </el-form-item
          ></el-col>
        </el-row>
        <el-row :gutter="1">
          <el-col :span="12">
            <el-form-item label="班级" prop="clsId">
              <el-select
                v-model="form.clsId"
                placeholder="请选择班级"
                filterable
                clearable
                style="width: 200px"
              >
                <el-option
                  v-for="item in clsList"
                  :key="item.clsId"
                  :label="item.clsName"
                  :value="item.clsId"
                />
              </el-select> </el-form-item
          ></el-col>
          <el-col :span="12">
            <el-form-item label="出生日期" prop="birthday">
              <el-date-picker
                clearable
                v-model="form.birthday"
                type="date"
                value-format="YYYY-MM-DD"
                placeholder="请选择出生日期"
              >
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="1">
          <el-col :span="12">
            <el-form-item label="方向" prop="directionId">
              <el-select
                v-model="form.directionId"
                placeholder="请选择方向"
                clearable
                style="width: 200px"
              >
                <el-option
                  v-for="item in directionList"
                  :key="item.id"
                  :label="item.directionName"
                  :value="item.id"
                />
              </el-select> </el-form-item
          ></el-col>
          <el-col :span="12">
            <el-form-item label="书院" prop="dormbuildingId">
              <el-select
                v-model="form.dormbuildingId"
                placeholder="请选择书院"
                clearable
                style="width: 200px"
              >
                <el-option
                  v-for="item in dormbuildingList"
                  :key="item.dormbuildingId"
                  :label="item.dormbuildingName"
                  :value="item.dormbuildingId"
                />
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="宿舍" prop="dormName">
              <el-input
                v-model="form.dormName"
                placeholder="请输入宿舍号"
              /> </el-form-item
          ></el-col>
        </el-row>
        <el-row :gutter="1">
          <el-col :span="12">
            <el-form-item label="身份证" prop="idCard">
              <el-input v-model="form.idCard" placeholder="请输入身份证" /> </el-form-item
          ></el-col>
          <el-col :span="12">
            <el-form-item label="政治面貌" prop="politicalStatus">
              <el-select v-model="form.politicalStatus" placeholder="请选择">
                <el-option
                  v-for="dict in cis_political"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.label"
                ></el-option>
              </el-select> </el-form-item
          ></el-col>
        </el-row>
        <el-row :gutter="1">
          <el-col :span="12"> </el-col>
          <el-col :span="12">
            <el-form-item label="户口类型" prop="householdType">
              <el-select v-model="form.householdType" placeholder="请选择">
                <el-option
                  v-for="dict in cis_household"
                  :key="dict.value"
                  :label="dict.label"
                  :value="dict.label"
                ></el-option>
              </el-select> </el-form-item
          ></el-col>
        </el-row>
        <el-row :gutter="1">
          <el-col :span="12">
            <el-form-item label="民族" prop="ethnicity">
              <el-select
                v-model="form.ethnicity"
                placeholder="请选择民族"
                clearable
                style="width: 200px"
              >
                <el-option
                  v-for="item in national"
                  :key="item"
                  :label="item"
                  :value="item"
                />
              </el-select> </el-form-item
          ></el-col>
          <el-col :span="12"
            ><el-form-item label="籍贯" prop="nativePlace">
              <el-input
                v-model="form.nativePlace"
                placeholder="请输入籍贯"
              /> </el-form-item
          ></el-col>
        </el-row>
        <el-row :gutter="1">
          <el-col :span="12"
            ><el-form-item label="监护人" prop="emergencyContact">
              <el-input
                v-model="form.emergencyContact"
                placeholder="请输入紧急联系人"
              /> </el-form-item
          ></el-col>
          <el-col :span="12">
            <el-form-item label="家人电话" prop="emergencyPhone">
              <el-input
                v-model="form.emergencyPhone"
                placeholder="请输入紧急联系电话"
              /> </el-form-item
          ></el-col>
        </el-row>
        <el-row :gutter="1">
          <el-col :span="12"
            ><el-form-item label="开户行" prop="issuingBank">
              <el-input
                v-model="form.issuingBank"
                placeholder="请输入开户行"
              /> </el-form-item
          ></el-col>
          <el-col :span="12"
            ><el-form-item label="银行卡号" prop="bankCard">
              <el-input
                v-model="form.bankCard"
                placeholder="请输入银行卡"
              /> </el-form-item
          ></el-col>
        </el-row>

        <el-form-item label="住址" prop="address">
          <el-input v-model="form.address" placeholder="请输入住址" />
        </el-form-item>
        <el-form-item label="生源地" prop="sourcePlace">
          <el-input v-model="form.sourcePlace" placeholder="请输入生源地" />
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </template>
    </el-dialog>
    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" v-model="upload.open" width="400px" append-to-body>
      <el-form :model="upload" ref="studentUploadRef">
        <el-form-item label="班级" prop="clsId">
          <el-select
            v-model="upload.clsId"
            placeholder="请选择班级"
            filterable
            clearable
            style="width: 200px"
          >
            <el-option
              v-for="item in clsList"
              :key="item.clsId"
              :label="item.clsName"
              :value="item.clsId"
            />
          </el-select>
        </el-form-item>
      </el-form>
      <el-upload
        ref="uploadRef"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url"
        :data="upload"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
      >
        <el-icon class="el-icon--upload"><upload-filled /></el-icon>
        <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
        <template #tip>
          <div class="el-upload__tip text-center">
            <div class="el-upload__tip">
              <el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
            </div>
            <span>仅允许导入xls、xlsx格式文件。</span>
            <el-link
              type="primary"
              :underline="false"
              style="font-size: 12px; vertical-align: baseline"
              @click="importTemplate"
              >下载模板</el-link
            >
          </div>
        </template>
      </el-upload>
      <template #footer>
        <div class="dialog-footer">
          <el-button type="primary" @click="submitFileForm">确 定</el-button>
          <el-button @click="upload.open = false">取 消</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="Student">
import { getToken } from "@/utils/auth";
import {
  listStudent,
  getStudent,
  delStudent,
  addStudent,
  updateStudent,
} from "@/api/infomanagement/student";
import { listDormbuilding } from "@/api/infomanagement/dormbuilding";
import { listCollege } from "@/api/infomanagement/college";
import { listCls } from "@/api/infomanagement/cls";
import { listDirection } from "@/api/directionmanagement/direction";
import { onMounted, computed, reactive } from "vue";
import { useRouter } from "vue-router";
const { proxy } = getCurrentInstance();
const { sys_user_sex, cis_political, cis_household } = proxy.useDict(
  "sys_user_sex",
  "cis_political",
  "cis_household"
);
const router = useRouter();

/**
 * 跳转至数据多维分析界面，传递学号和姓名参数
 * @param {string} stuCode - 学号
 * @param {string} realname - 学生姓名
 */
function navigateToMultiDimensionalAnalysis(stuCode, realname) {
  router.push({
    path: '/analyzemanagemen/dataanalysis',
    query: {
      stuCode,
      realname
    }
  });
}

const studentList = ref([]);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");

/*** 用户导入参数 */
const upload = reactive({
  clsId: "",
  // 是否显示弹出层（用户导入）
  open: false,
  // 弹出层标题（用户导入）
  title: "",
  // 是否禁用上传
  isUploading: false,
  // 是否更新已经存在的用户数据
  updateSupport: 0,
  // 设置上传的请求头部
  headers: { Authorization: "Bearer " + getToken() },
  // 上传的地址
  url: import.meta.env.VITE_APP_BASE_API + "/infomanagement/student/importData",
});
const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    stuCode: null,
    campusId: null,
    realname: null,
    sex: null,
    birthday: null,
    idCard: null,
    politicalStatus: null,
    ethnicity: null,
    phone: null,
    emergencyContact: null,
    emergencyPhone: null,
    nativePlace: null,
    address: null,
    sourcePlace: null,
    householdType: null,
    dormbuildingId: null,
    dormbuildingName: null,
    dormId: null,
    dormName: null,
    majorId: null,
    majorName: null,
    clsId: null,
    clsName: null,
    collegeId: null,
    collegeName: null,
    directionId: null,
    bankCard: null,
    issuingBank: null,
    photo: null,
    status: null,
  },
  rules: {
    stuCode: [
      { required: true, message: "学号不能为空", trigger: "blur" },
      { length: 12, message: "课程号长度为12位", trigger: "blur" },
    ],
    realname: [{ required: true, message: "姓名不能为空", trigger: "blur" }],
    idCard: [{ required: true, message: "身份证不能为空", trigger: "blur" }],
    sex: [{ required: true, message: "性别不能为空", trigger: "blur" }],
    clsId: [{ required: true, message: "班级不能为空", trigger: "blur" }],
    phone: [{ required: true, message: "手机不能为空", trigger: "blur" }],
    dormbuildingId: [{ required: true, message: "书院不能为空", trigger: "blur" }],
    dormName: [{ required: true, message: "宿舍号不能为空", trigger: "blur" }],
  },
});

const { queryParams, form, rules } = toRefs(data);
// 列显隐信息
const columns = ref([
  { key: 0, label: `id`, visible: true },
  { key: 1, label: `学生id`, visible: false },
  { key: 2, label: `学号`, visible: true },
  { key: 3, label: `学生姓名`, visible: true },
  { key: 4, label: `手机`, visible: true },
  { key: 5, label: `用户性别`, visible: true },
  { key: 6, label: `出生日期`, visible: false },
  { key: 7, label: `身份证`, visible: false },
  { key: 8, label: `政治面貌`, visible: false },
  { key: 9, label: `民族`, visible: false },
  { key: 10, label: `籍贯`, visible: false },
  { key: 11, label: `住址`, visible: false },
  { key: 12, label: `生源地`, visible: false },
  { key: 13, label: `户口性质`, visible: false },
  { key: 14, label: `书院`, visible: false },
  { key: 15, label: `宿舍`, visible: true },
  { key: 16, label: `学院`, visible: true },
  { key: 17, label: `专业`, visible: false },
  { key: 18, label: `班级`, visible: true },
  { key: 19, label: `银行卡`, visible: false },
  { key: 20, label: `开户行`, visible: false },
  { key: 21, label: `监护人`, visible: false },
  { key: 22, label: `家人电话`, visible: false },
  { key: 23, label: `状态`, visible: true },
  { key: 24, label: `方向`, visible: true },
]);
/* 获取需要选择的数据 */
const dormbuildingList = ref([]);
const collegeList = ref([]);
const clsList = ref([]);
const directionList = ref([]);
const clsQueryList = computed(() => {
  return queryParams.value.collegeId
    ? clsList.value.filter((item) => item.collegeId === queryParams.value.collegeId)
    : clsList.value;
});
//const clsImportList = clsList.value

/* function remoteMethod(query){
  if(query){
    clsImportList.value= clsList.value.filter((item)=>{return item.clsDisplayname.includes(query)})
  }else{
    clsImportList.value=[...clsList.value]
  }
} */

/** 根据方向ID获取方向名称 */
function getDirectionName(directionId) {
  if (!directionId) return "";
  const direction = directionList.value.find((item) => item.id === directionId);
  return direction ? direction.directionName : "";
}

/** 查询其它列表 */
function getOtherList() {
  /** 查询二级学院列表 */
  listCollege().then((res) => {
    collegeList.value = res.rows;
  });

  /** 查询书院列表 */
  listDormbuilding().then((response) => {
    dormbuildingList.value = response.rows;
  });

  listCls().then((response) => {
    clsList.value = response.rows;
  });

  /** 查询方向列表 */
  listDirection().then((response) => {
    directionList.value = response.rows;
  });
}

/** 查询学生管理列表 */
function getList() {
  loading.value = true;
  listStudent(queryParams.value).then((response) => {
    studentList.value = response.rows;
    total.value = response.total;
    loading.value = false;
  });
}

// 取消按钮
function cancel() {
  open.value = false;
  reset();
}

// 表单重置
function reset() {
  form.value = {
    userId: null,
    stuCode: null,
    campusId: null,
    realname: null,
    sex: null,
    birthday: null,
    idCard: null,
    politicalStatus: null,
    ethnicity: null,
    phone: null,
    emergencyContact: null,
    emergencyPhone: null,
    nativePlace: null,
    address: null,
    sourcePlace: null,
    householdType: null,
    dormbuildingId: null,
    dormbuildingName: null,
    dormId: null,
    dormName: null,
    majorId: null,
    majorName: null,
    clsId: null,
    clsName: null,
    collegeId: null,
    collegeName: null,
    directionId: null,
    teacherId: null,
    teacherName: null,
    counselorId: null,
    counselorName: null,
    bankCard: null,
    issuingBank: null,
    photo: null,
    status: null,
    delFlag: null,
    createBy: null,
    createTime: null,
    updateBy: null,
    updateTime: null,
  };
  proxy.resetForm("studentRef");
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm("queryRef");
  handleQuery();
}

// 多选框选中数据
function handleSelectionChange(selection) {
  ids.value = selection.map((item) => item.userId);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

/** 新增按钮操作 */
function handleAdd() {
  reset();
  open.value = true;
  title.value = "添加学生管理";
}

/** 修改按钮操作 */
function handleUpdate(row) {
  reset();
  const _userId = row.userId || ids.value;
  getStudent(_userId).then((response) => {
    form.value = response.data;
   
    open.value = true;
    title.value = "修改学生管理";
  });
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["studentRef"].validate((valid) => {
    if (valid) {
      proxy.$modal.loading("正在提交中...");
      form.value.dormbuildingName = dormbuildingList.value.find(
        (item) => item.dormbuildingId === form.value.dormbuildingId
      )?.dormbuildingName;

      if (form.value.userId != null) {
        updateStudent(form.value)
          .then((response) => {
            proxy.$modal.closeLoading();
            proxy.$modal.msgSuccess("修改成功");
            open.value = false;
            getList();
          })
          .catch(() => { proxy.$modal.closeLoading(); });
      } else {
        addStudent(form.value)
          .then((response) => {
            proxy.$modal.closeLoading();
            proxy.$modal.msgSuccess("新增成功");
            open.value = false;
            getList();
          })
          .catch(() => { proxy.$modal.closeLoading(); });
      }
    }
  });
}

/** 删除按钮操作 */
function handleDelete(row) {
  const _userIds = row.userId || ids.value;
  proxy.$modal
    .confirm('是否确认删除学生管理编号为"' + _userIds + '"的数据项？')
    .then(function () {
      return delStudent(_userIds);
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess("删除成功");
    })
    .catch(() => {});
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download(
    "infomanagement/student/export",
    {
      ...queryParams.value,
    },
    `student_${new Date().getTime()}.xlsx`
  );
}
/** 导入按钮操作 */
function handleImport() {
  upload.title = "学生导入";
  upload.open = true;
  upload.count = "";
}
/**文件上传中处理 */
const handleFileUploadProgress = (event, file, fileList) => {
  upload.isUploading = true;
};

/** 文件上传成功处理 */
const handleFileSuccess = (response, file, fileList) => {
  upload.open = false;
  upload.isUploading = false;
  proxy.$refs["uploadRef"].handleRemove(file);
  proxy.$alert(
    "<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" +
      response.msg +
      "</div>",
    "导入结果",
    { dangerouslyUseHTMLString: true }
  );
  getList();
};
/** 下载模板操作 */
function importTemplate() {
  proxy.download(
    "system/user/importTemplate",
    {},
    `user_template_${new Date().getTime()}.xlsx`
  );
}
/** 提交上传文件 */
function submitFileForm() {
  proxy.$refs["studentUploadRef"].validate((valid) => {
    if (valid) {
      proxy.$refs["uploadRef"].submit();
    }
  });
}
getList();
onMounted(() => {
  getOtherList();
  getList();
});
const national = [
  "汉族",
  "壮族",
  "满族",
  "回族",
  "苗族",
  "维吾尔族",
  "土家族",
  "彝族",
  "蒙古族",
  "藏族",
  "布依族",
  "侗族",
  "瑶族",
  "朝鲜族",
  "白族",
  "哈尼族",
  "哈萨克族",
  "黎族",
  "傣族",
  "畲族",
  "傈僳族",
  "仡佬族",
  "东乡族",
  "高山族",
  "拉祜族",
  "水族",
  "佤族",
  "纳西族",
  "羌族",
  "土族",
  "仫佬族",
  "锡伯族",
  "柯尔克孜族",
  "达斡尔族",
  "景颇族",
  "毛南族",
  "撒拉族",
  "布朗族",
  "塔吉克族",
  "阿昌族",
  "普米族",
  "鄂温克族",
  "怒族",
  "京族",
  "基诺族",
  "德昂族",
  "保安族",
  "俄罗斯族",
  "裕固族",
  "乌孜别克族",
  "门巴族",
  "鄂伦春族",
  "独龙族",
  "塔塔尔族",
  "赫哲族",
  "珞巴族",
];
</script>
